<template>
  <view class="container">
    <view class="main">
      <rich-text :nodes="content" :data-nodes="content"></rich-text>
    </view>
  </view>
</template>

<script>
  import htmlParser from '@/common/js/html-parser';
  export default {
    data() {
      return {
        content: '',  
        type: 1,   //类型:1=用户协议,2=隐私政策
      }
    },
    onLoad(e) {
       this.type = e.type;
       var name_arr = ["用户协议","隐私政策"];
       uni.setNavigationBarTitle({
         title: name_arr[this.type-1]
       })
      this.getSetting()
    },
    methods: {
      getSetting() {
        this.$api.sendRequest({
          url: '/api/site/info',
          data: {},
          success: res => {
            if(res.code == 0) {
              
              if(this.type == 1) {
                if (res.data.user_agreement) this.content = htmlParser(res.data.user_agreement);
              }else if(this.type == 2) {
                if (res.data.privacy_agreement) this.content = htmlParser(res.data.privacy_agreement);
              }else {
                
              }
              
            }
            
          }
        })
      },
    }
  }
</script>

<style lang="scss" scoped>
.main {
  margin: 30rpx;
  font-size: 30rpx;
  color: #1C274C;
}
</style>
